package com.sword.common.utils;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @description: 时间工具类
 * @author：Lv.RJ
 * @version: 1.0.0
 * @create: 2025/02/19
 **/
public class DateUtil {
    public static void main(String[] args) {
        String formattedDate = format("uuuuMMdd");
        System.out.println(formattedDate);
    }

    /**
     * 时间转换
     * @param format  "uuuuMMdd" uuuu来表示四位数的年份 "uuuu-MM-dd HH:mm:ss"
     * @return 20250250
     */
    public static String format(String format) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
        String formattedDate = LocalDate.now().format(formatter);
        return formattedDate;
    }
}
